
# Copyright (C), 2020,WHU.
#   File name:demo.py      /
#   Created by:
#   Version:1.0.0        
#   Date: 
#   Description:  
#   
# Dependencies：

# ChangeLog:        // 修改历史记录列表，每条修改记录应包括修改日期、修改
#                   // 者及修改内容简述  
import os
import sys
import numpy as np
from data import *
from Lenet5 import *
from  train import *
import time
#log类，存储计算得到的loss结果
class Logger(object):
    def __init__(self, stream=sys.stdout):
        output_dir = "log"
        if not os.path.exists(output_dir):
            os.makedirs(output_dir)
        log_name = '{}.log'.format(time.strftime('%Y-%m-%d-%H-%M'))
        filename = os.path.join(output_dir, log_name)

        self.terminal = stream
        self.log = open(filename, 'a+')

    def write(self, message):
        self.terminal.write(message)
        self.log.write(message)

    def flush(self):
        pass

if __name__ == '__main__':
    sys.stdout = Logger(sys.stdout)
    #定义数据集路径并读取
    #设定使用的优化算法及参数
    #训练与测试